package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_ProductCategory 产品分类
 *
 */
public class TestData_TB_ProductCategory
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_ProductCategory saveMust(
		org.springframework.context.ApplicationContext context
		
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_ProductCategory");
		return (TB_ProductCategory)repository.save(newMust(
				
			));
	}
	
	public static TB_ProductCategory newMust(
		
	){
		return new TB_ProductCategory(new TB_ProductCategory.MustProperties() {
			/** 名称 */
			@Override public String getName(){
				return Generator.generate(0, 100);
			}
			/** 级别 */
			@Override public Integer getLevel(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.intRandom(0, Integer.MAX_VALUE);
			}
			/** 代码 */
			@Override public String getNumber(){
				return Generator.generate(0, 100);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_ProductCategory saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ProductCategory parent
	,bairui.international.model.domain.jpa.TB_ProductCategory root
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_ProductCategory");
		return (TB_ProductCategory)repository.save(newAll(
				parent
				,root
			));
	}
	
	public static TB_ProductCategory newAll(
		bairui.international.model.domain.jpa.TB_ProductCategory parent
	,bairui.international.model.domain.jpa.TB_ProductCategory root
	){
		return new TB_ProductCategory(
			new TB_ProductCategory.MustProperties() {
				/** 名称 */
				@Override public String getName(){
					return Generator.generate(0, 100);
				}
				/** 级别 */
				@Override public Integer getLevel(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.intRandom(0, Integer.MAX_VALUE);
				}
				/** 代码 */
				@Override public String getNumber(){
					return Generator.generate(0, 100);
				}
			},
			new TB_ProductCategory.OptionalSingleProperties() {
				/** 父 */
				@Override public bairui.international.model.domain.jpa.TB_ProductCategory getParent(){
					return parent;
				}
				/** 根 */
				@Override public bairui.international.model.domain.jpa.TB_ProductCategory getRoot(){
					return root;
				}
			}
		);
	}
	

}
